<?xml version="1.0" encoding="UTF-8" ?>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<script type="text/javascript" src="../../../js/jquery.js"></script>
<script type="text/javascript" src="../../../js/jquery-ui-personalized.min.js"></script>
<script type="text/javascript" src="../js/common.js"></script>
<script type="text/javascript" src="../js/mail.js"></script>
<link type="text/css" href="../../../style/theme/ui.all.css" rel="stylesheet" />
<link type="text/css" href="../style/style.css" rel="stylesheet"/>

<title>邮件列表</title>
</head>
<body>
	<h1>${dormSupervisor.building.name }的邮件列表</h1>
	<div class="ajaxMessage"></div>
	<div>
		<form action="mailList.do" method="get" name="mailDTO" class="filterForm">
			<select name="type">
				<option value="building">楼栋</option>
				<option value="dormitory">寝室</option>				
			</select>
			<span class="dormitoryInput">
				<label for="dormitoryName">寝室名称:</label>
				<input type="text" name="dormitory" id="dormitoryName"/><span class="warning"></span>
			</span>
			<label>起始时间</label>
			<input type="text" name="fromDate" class="datePicker"/>
			<label>结束时间</label>
			<input type="text" name="toDate" class="datePicker"/>
			<input type="submit" name="submit" value="提交"/>
		</form>
	</div>
	<input type="hidden" name="buildingId" value="${dormSupervisor.building.id }"/>
	
	<c:choose>
		<c:when test="${!empty mails.list}">
			<div class="mailTool">
				<button class="ajaxEvent" name="delete" value="删除">删除</button>
			</div>		
			<div class="modifyDialog" title="修改邮件">
				<form action="updateMail.do" method="post" name="mailDTO">
<!--					<div class="ajaxMessage"></div>-->
					<input type="hidden" name="mailId" value=""/>
					<div>
						<label for="dormitory">寝室名：</label>
						<div>
							<input id="dormitory" class="ajaxEvent" type="text" name="dormitory"/>*
							<span class="warning"></span>
						</div>
					</div>
					<div>
						<label for="student">学生：</label>
						<div>
							<div><input id="student" type="text" name="student"/>*</div>
							<div id="studentList" ><table></table></div>
						</div>			
					</div>
					<div>
						<label for="description">说明：</label>
						<div>
							<textarea rows="5" cols="20" id="description" name="description"></textarea>*
						</div>
					</div>
					
				</form>
			</div>	
			<table border="1px" id="mailList">
				<thead>
					<tr>
						<td><input type="checkbox" name="selectAll"/></td><td>ID</td>
						<td>寝室</td><td>姓名</td><td>描述</td><td>到达时间</td><td>查看/修改</td>
					</tr>
				</thead>
				<tbody>
					<c:forEach items="${mails.list}" var="mail">
						<tr>
							<td><input type="checkbox" name="mailId" value="${mail.id }"/></td>
							<td title="id">${mail.id }</td><td title="dormitory">${mail.dormitory.name }</td>
							<td title="student">${mail.student}</td><td title="description">${mail.description }</td>
							<td title="arriveDate"><fmt:formatDate value="${mail.arriveDate}" pattern="yyyy-MM-dd HH:mm"/></td>
							<td><input type="button" name="modify" value="查看/修改" mailId="${mail.id }"/></td>				
						</tr>
					</c:forEach>
				</tbody>
			</table>
			<div class="mailTool">
				<button name="delete" value="删除">删除</button>
			</div>	
		</c:when>
		<c:otherwise>
			<p>没有找到符合条件的邮件</p>
		</c:otherwise>
	</c:choose>
</body>
</html>